﻿@using ZX.Tools
@using ZX.Model
@model MyCostBill
@{
    Sys_UserModel user = ViewBag.User;
    string[] descs = (Model.ADesc + "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
    int positionCounts = ViewBag.PositionCounts;
    List<Sys_User> userList = ViewBag.UserList ?? new List<Sys_User>();
}
<link href="~/Static/styles/bootstrap.min.css" rel="stylesheet" />
<link href="~/Static/js/layui/css/layui.css" rel="stylesheet" />
<script src="/Static/js/jquery/jquery-1.11.1.min.js"></script>
<script src="~/Static/js/layui/layui.js"></script>
<div class='row page-content'>
    <div class='panel'>
        <div class='panel-heading'><strong><i class='icon-building'></i>费用报销单</strong></div>
        <div class='panel-body'>
            <form action="/MyCostBill/SaveApproval" method="post" class="form" id="formMyCostBill">
                <input type="hidden" name="Id" value="@Model.Id" />
                <input type="hidden" name="FK_ApprovalId" value="@Model.FK_ApprovalId" />
                <input type="hidden" name="status" value="@ApplyStatus.驳回.ToInt()" />
                <input type="hidden" name="deptId" value="@user.Fk_DeptId" />
                <table class='table table-bordered' style="border: 1px solid #ddd;">
                    <tr>
                        <th class='text-center w-50px'>申请部门</th>
                        <td>
                            @user.DeptName
                        </td>
                        <th class="text-center w-120px">申请人</th>
                        <td>
                            @user.RealName
                        </td>
                        <th class='text-center w-100px'>日期</th>
                        <td>
                            @(Model.AddTime.ToDateFormat("yyyy-MM-dd"))
                        </td>
                    </tr>
                    <tr>
                        <th class="text-center w-120px">用途</th>
                        <td colspan="3">
                            <ul id="ullist">
                                @for (int i = 0; i < descs.Length; i++)
                                {
                                    <li>
                                        @((i + 1) + "." + descs[i])
                                    </li>
                                }
                            </ul>
                        </td>
                        <th class="text-center w-60px">预计费用</th>
                        <td>
                            @(Model.TotalMoney)元
                        </td>
                    </tr>
                    <tr>
                        <th class='text-center w-50px'>原借款</th>
                        <td>
                            @Model.Advance
                        </td>
                        <th class="text-center w-120px">退/补</th>
                        <td>
                            @Model.Retrieve
                        </td>
                    </tr>
                    <tr>
                        <th class='text-center w-50px'>报销人</th>
                        <td>
                            @Model.ReimburseUser
                        </td>
                        <th class="text-center w-120px">领款人</th>
                        <td>
                            @Model.ReceiveUser
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" class="text-center">
                            <strong>审批意见</strong>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="2" class="text-center">部门负责人意见</td>
                        <td colspan="2" class="text-center">综合部意见</td>
                        <td colspan="2" class="text-center">总经理意见</td>
                    </tr>
                    @{

                        string userSign0 = "";
                        string userSign1 = "";

                        try
                        {
                            userSign0 = userList[0].USgin;
                        }
                        catch { }

                        try
                        {
                            userSign1 = userList[1].USgin;
                        }
                        catch { }

                    }
                    <tr>
                        <td colspan="2" class="text-center">
                            <div>
                                @{
                                    //如果申请单只走部门负责人审批,则仅仅显示部门负责人
                                    if (positionCounts > 1)
                                    {
                                        if (userSign1.IsNotNullOrEmpty())
                                        {
                                            <img src="@userSign1" style="width:200px;height:50px;margin-left:7px;" />
                                        }
                                    }
                                    else
                                    {
                                        if (userSign0.IsNotNullOrEmpty())
                                        {
                                            <img src="@userSign0" style="width:200px;height:50px;margin-left:7px;" />
                                        }

                                    }
                                }
                            </div>
                        </td>
                        <td colspan="2" class="text-center"></td>
                        <td colspan="2" class="text-center">
                            <div>
                                @{
                                    //如果申请单只走部门负责人审批,则仅仅显示部门负责人
                                    if (positionCounts > 1 && userSign0.IsNotNullOrEmpty())
                                    {
                                        <img src="@userSign0" style="width:200px;height:50px;margin-left:7px;" />
                                    }
                                }
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        onprint();
    });
    function printHtml(html) {
        var bodyHtml = html;
        document.body.innerHTML = html;
        window.print();
        document.body.innerHTML = bodyHtml;
    }
    function onprint() {
        var html = $(".panel-body").html();
        printHtml(html);
    }
</script>
